#include "vectorfunctions.h"
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <sstream>


int substract(char s1[], int l1, char s2[], int l2, char result[])
{
	int i, digit_1=0, digit_2=0, difference=0, borrow=0;
	char diff;	
	mirror(s1, l1);
	mirror(s2, l2);
	for( i=0;i<min(l1, l2);i++)
                {
                   digit_1=(int(s1[i])-48);
                   digit_2=(int(s2[i])-48);

                   difference=(digit_1-digit_2-borrow);

                   if(difference<0)
                  {
                     difference+=10;
                     borrow=1;
                  }

                   else
                  borrow=0;
		
		diff=(char(difference)+48);
		result[i]=diff;
	}
	if(l1<l2)
		for(i=l1; i<l2; i++)
			result[i]=s2[i];
	else 
		for(i=l2; i<l1; i++)
			result[i]=s1[i];
	mirror(result, i);
return i;
}

int main()
{
	int i,j, l1=0, l2=0, lr;
	char c;
	char s1[100], s2[100], result[100];
	cout<<"Enter first number : ";
	while((c=getchar())!='\n'){
		s1[l1]=c;
		++l1;
	}
	cout<<"Enter second number : ";
	while((c=getchar())!='\n'){
		s2[l2]=c;
		++l2;
	}
	lr = substract(s1, l1, s2, l2, result);
	printVector(result, lr);
		
	
return 0;
}
